'use strict';
const db = uniCloud.database();
exports.main = async (event, context) => {
  //event为客户端上传的参数
  const collection = db.collection('tasks');
  // let page=event.page-1;
  // let skip_count=page*event.page_size
 let user_id=event.user_id;
 let type=event.type;
 let tasks
 if(type==0){
	tasks =await collection.where({"receiver_id":user_id}).orderBy("time", "desc").get()
 }else if(type==1){
	 tasks=await collection.where({"user_id":user_id}).orderBy("time", "desc").get()
 }
 
  return {"status":2, "tasks":tasks.data}
};
